<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS关键帧动画示例</title>
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: Arial, sans-serif;
            line-height: 1.6;
            padding: 2rem;
            background-color: #f0f0f0;
        }

        .container {
            max-width: 800px;
            margin: 0 auto;
        }

        h1 {
            text-align: center;
            margin-bottom: 2rem;
            color: #333;
        }

        .example-section {
            background: white;
            padding: 2rem;
            margin-bottom: 2rem;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }

        h2 {
            margin-bottom: 1rem;
            color: #444;
        }

        /* 1. 基础动画 */
        @keyframes bounce {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-20px); }
        }

        .bounce-ball {
            width: 50px;
            height: 50px;
            background-color: #007bff;
            border-radius: 50%;
            animation: bounce 1s ease-in-out infinite;
        }

        /* 2. 加载动画 */
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .loader {
            width: 40px;
            height: 40px;
            border: 4px solid #f3f3f3;
            border-top: 4px solid #3498db;
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }

        /* 3. 进度条动画 */
        @keyframes progress {
            0% { width: 0; }
            100% { width: 100%; }
        }

        .progress-container {
            width: 100%;
            height: 20px;
            background-color: #f3f3f3;
            border-radius: 10px;
            overflow: hidden;
        }

        .progress-bar {
            height: 100%;
            background-color: #4CAF50;
            animation: progress 3s ease-in-out infinite;
        }

        /* 4. 脉冲动画 */
        @keyframes pulse {
            0% {
                transform: scale(1);
                box-shadow: 0 0 0 0 rgba(255, 82, 82, 0.7);
            }
            
            70% {
                transform: scale(1.05);
                box-shadow: 0 0 0 10px rgba(255, 82, 82, 0);
            }
            
            100% {
                transform: scale(1);
                box-shadow: 0 0 0 0 rgba(255, 82, 82, 0);
            }
        }

        .pulse-button {
            width: 100px;
            height: 100px;
            background-color: #ff5252;
            color: white;
            border: none;
            border-radius: 50%;
            cursor: pointer;
            animation: pulse 2s infinite;
        }

        /* 5. 文字动画 */
        @keyframes slideIn {
            0% {
                opacity: 0;
                transform: translateY(20px);
            }
            100% {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .animated-text span {
            display: inline-block;
            animation: slideIn 0.5s ease-out backwards;
        }

        .animated-text span:nth-child(1) { animation-delay: 0.1s; }
        .animated-text span:nth-child(2) { animation-delay: 0.2s; }
        .animated-text span:nth-child(3) { animation-delay: 0.3s; }
        .animated-text span:nth-child(4) { animation-delay: 0.4s; }

        /* 6. 背景动画 */
        @keyframes gradient {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }

        .gradient-bg {
            width: 100%;
            height: 100px;
            background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
            background-size: 400% 400%;
            animation: gradient 15s ease infinite;
            border-radius: 8px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>CSS关键帧动画示例</h1>

        <div class="example-section">
            <h2>1. 基础动画</h2>
            <p>简单的弹跳动画：</p>
            <div class="bounce-ball"></div>
        </div>

        <div class="example-section">
            <h2>2. 加载动画</h2>
            <p>旋转加载动画：</p>
            <div class="loader"></div>
        </div>

        <div class="example-section">
            <h2>3. 进度条动画</h2>
            <p>进度条加载动画：</p>
            <div class="progress-container">
                <div class="progress-bar"></div>
            </div>
        </div>

        <div class="example-section">
            <h2>4. 脉冲动画</h2>
            <p>按钮脉冲效果：</p>
            <button class="pulse-button">点击我</button>
        </div>

        <div class="example-section">
            <h2>5. 文字动画</h2>
            <p>文字滑入效果：</p>
            <div class="animated-text">
                <span>欢</span>
                <span>迎</span>
                <span>你</span>
                <span>！</span>
            </div>
        </div>

        <div class="example-section">
            <h2>6. 背景动画</h2>
            <p>渐变背景动画：</p>
            <div class="gradient-bg"></div>
        </div>
    </div>
</body>
</html>
